<?php
$error = "";
if(isset($_POST['btSubmit'])){
    $username = $_POST['txtUsername'];
    $password = $_POST['txtPassword'];
    
    $userDto = $Bus->User->userLogin($username, $password);
    if(!$userDto){
        $error = "Tài khoản hay mật khẩu không đúng.";
    }else{
        $_SESSION['user'] = $userDto->toArray();
        $url = url('admin','index');
        redirect($url);
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title><?php echo $title; ?></title>
<link href="css/admin-reset.css" media="screen" rel="stylesheet" type="text/css" />
<link href="css/admin-style.css" media="screen" rel="stylesheet" type="text/css" />
<!--[if IE]>
<link href="css/ie.css" media="screen" rel="stylesheet" type="text/css">
<![endif]-->
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/jquery-custom.js"></script>
</head>
<body>
<div class="shadow-login"></div><!-- end div .shadow-login -->
<!-- BEGIN LOGIN -->
<div id="login">
    <p class="logo"><a href="" title="Administrator">Admin Panel</a></p>
    <div class="box-out">
    	<div class="box-in">
                
            <?php if(!empty($error)) {?>
    		<div class="notification error">
    			<div class="messages"><?php echo $error; ?> <div class="close"><img src="css/images/icon/close.png" alt="close" /></div></div>
    		</div><!-- end div .notification info -->
            <?php }?>
            
    		<form action="" method="post">
    			<fieldset>
    				<label>Tài khoản</label><input type="text" class="text" name="txtUsername" />
    				<label>Mật khẩu</label><input type="password" class="text" name="txtPassword" />
    				<input type="submit" class="submit" value="Đăng nhập" name="btSubmit" />
    			</fieldset>
    		</form>
    	</div><!-- end div .box-in -->
    </div><!-- end div .box-out -->
</div><!-- end div #login -->
<!-- END LOGIN -->
</body>
</html>
